package com.briup.jz.web.controller;

import com.briup.jz.bean.Order;
import com.briup.jz.service.IOrderService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Api(description="订单接口")
@RestController
@RequestMapping("order")
public class OrderController {

	@Autowired
    private IOrderService iOrderService ;

    @ApiOperation(value = "保存或更新订单分类")
    @ApiImplicitParams({
    @ApiImplicitParam(name="id",value = "编号",paramType = "form"),
     @ApiImplicitParam(name="orderTime",value = "订单时间",paramType = "form"),
    @ApiImplicitParam(name="serviceTime",value = "服务时间",paramType = "form"),
     @ApiImplicitParam(name="total",value = "费用",paramType = "form"),
    @ApiImplicitParam(name="status",value = "状态",paramType = "form"),
    @ApiImplicitParam(name="remark",value = "标注",paramType = "form"),
    @ApiImplicitParam(name="customerId",value = "顾客编号",paramType = "form"),
    @ApiImplicitParam(name="addressId",value = "地址编号",paramType = "form"),
    @ApiImplicitParam(name="employeeId",value = "员工编号",paramType = "form"),
    
 })
    @PostMapping("saveorupdate")
    public Message saveorupdate(Order order){
        iOrderService.saveOrUpdate(order);
        return MessageUtil.success("操作成功");
    }
    @ApiOperation(value = "按id查询订单分类")
    @GetMapping("query")
    public  Message query(Long id){
        Order orders = iOrderService.query(id);
        return MessageUtil.success(orders);
    }
    
    @ApiOperation(value = "查询全部订单")
    @GetMapping("findAll")
    public Message findAll() {
    	return MessageUtil.success(iOrderService.findAll());
    }
    
    
    @ApiOperation(value = "根据id删除订单分类")
    @GetMapping("delete")
    public  Message delete(Long id){
        iOrderService.deleteById(id);
        return MessageUtil.success("操作成功");
    }
}
